Modern computer graphics are rendered using a shader or a kernel. In general, the shader (or kernel) is used to determine levels of color within an image, produce special effects, and apply post-processing operations. A shader typically is programmed to operate using a shading language and can be coded for a particular graphics processor. Such shading languages are often used to program a pipeline that allows for customized effects. For example, the position, hue, saturation, brightness, and contrast of all pixels, vertices, and textures used to construct a final image can be altered dynamically, using algorithms defined in the shader.
In general, there are a number of types of shaders. The various shaders can reference constants that may be used to affect the behavior of the shader. For example, a shader program can use, a local constant and a global constant. Local constants are defined in the shader and cannot change while global constants can be changed by the application any time before executing the shader. Many modern computer applications (e.g., games, desktop managers, or the like) use global constants to control various settings (e.g., 3D settings, visual quality, lighting effects, resolution, size of depth buffer, number of samples per MSAA, or the like). Such settings cannot change during shader execution. However, since the application can change global constants any time before the shader execution, the value is often unknown when the shader is compiled. As such, the shader compiler cannot fully optimize the shader based on the value of the global constants. As a result, the overall performance of the shader may decrease while memory pressure and power consumption of the shader may increase. Furthermore, any change to the shader itself using conventional pipelines requires the shader to be recompiled, which further reduces efficiency. It is with respect to the above, that the present disclosure is provided.